<?php

namespace Diablo7\HyperfPulsar;

use Swoole\Coroutine\Http\Client;

class PulsarClient extends Client
{
    /**
     * @var PulsarEndpoint
     */
    public $endpoint;

    public function __construct(PulsarEndpoint $endpoint)
    {
        parent::__construct($endpoint->getHost(), $endpoint->getPort(), $endpoint->getScheme()==="wss");

        if($endpoint->getScheme()==="wss") {
            $this->set($endpoint->getSettings());
        }
    }

    public function connect() :PulsarClient
    {
        return $this->upgrade($this->endpoint->getPath()."?".$this->endpoint->getQuery());
    }


    public function ping()
    {

    }
}